---
title: "SQL-015: Purge completed tasks"
summary: Batch-delete tasks already flagged completed that are older than a retention window.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-08-21
library: SAIF.Business.Tasks
reference_type: embedded
---

# SQL-015 Purge completed tasks

Deletes tasks already flagged deleted/completed that are older than a caller-supplied retention window, by calling the Oracle stored procedure `PK82036_Task.Task_Purge`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-015 |
| **Operation type** | Delete |
| **Execution method** | Stored procedure |
| **Database** | Oracle |
| **Schema** | `[unqualified]`** |
| **Command type** | StoredProcedure |
| **Business object** | N/A (Application layer) |
| **Criteria property** | N/A |
| **Lifecycle method** | N/A |
| **Application class** | `clsTaskCollection` (`Shared PurgeTasks`) |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:intasksourcecode` | Input | String | 5 | Source system whose tasks are purged |
| `:intaskcategorycode` | Input | String | 5 | Category whose tasks are purged |
| `:inkeepdays` | Input | String | 5 | Retention window in days (passed as a string) |
| `:outdelrows` | Output | `DbType.String` | 15 | Number of purged rows; converted with `CInt` by the caller |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [TASK](../database-tables.md#task) | DELETE | N/A — stored procedure (deletes from `TASK`)** |

## Sample SQL

```sql
-- CommandType.StoredProcedure, RequestType = Scalar, DataRequest.ID = "IMG0001_Purge_Task"
CALL PK82036_Task.Task_Purge(
  :intasksourcecode,
  :intaskcategorycode,
  :inkeepdays,
  :outdelrows)
```

`:outdelrows` is an OUT parameter (`DbType.String`, length 15) read back via `DataRequest.ParmValue("outdelrows")` and converted with `CInt`. The procedure body resides in the Oracle database and was not retrieved in this environment.**

## Operations and processes
- [Purge completed tasks](../operations/purge-completed-tasks.md)

## Sources
- SAIF.Business.Tasks/clsTaskCollection.vb
